package com.study.meng.bigevent.service.impl;

import com.github.pagehelper.PageHelper;
import com.study.meng.bigevent.entity.Article;
import com.study.meng.bigevent.entity.PageBean;
import com.study.meng.bigevent.mapper.ArticleMapper;
import com.study.meng.bigevent.service.ArticleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleMapper articleMapper;

    @Override
    public boolean add(Article article) {
        return articleMapper.add(article);
    }

    @Override
    public PageBean<Article> list(Integer page, Integer pageSize, Integer categoryId, String state,
                                  Integer createUser) {
        PageHelper.startPage(page, pageSize);
        List<Article> articles = articleMapper.list(categoryId, state, createUser);
        return new PageBean<>(articles);
    }

    @Override
    public Integer countByCategoryId(Integer id) {
        return articleMapper.countByCategoryId(id);
    }


}
